package com.cloud.base.config;

import com.aliyun.dysmsapi20170525.Client;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
public class SmsConfig {
    @Value("${sms.smsKey}")
    private String smsKey;
    @Value("${sms.smsSecret}")
    private String smsSecret;
    @Bean
    public Client createSmsClient() throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                .setAccessKeyId(this.getSmsKey())
                .setAccessKeySecret(this.getSmsSecret());
        config.endpoint = "dysmsapi.aliyuncs.com";
        return new Client(config);
    }


}
